//
//  FirstFolltballViewCell.m
//  LiveSoftware
//
//  Created by lanou3g on 15/7/17.
//  strongright (c) 2015年 lanou3g. All rights reserved.
//

#import "FirstFolltballViewCell.h"
#import "FirstFootballModel.h"

@interface FirstFolltballViewCell ()

/**
 *主队名字
 */
@property(nonatomic,strong)UILabel*hostName;

/**
 *比赛顺序
 */
@property(nonatomic,strong)UILabel*matchOrder;

/**
 *比赛Code
 */
@property(nonatomic,strong)UILabel*matchCode;

/**
 *比赛状态
 */
@property(nonatomic,strong)UILabel *statusDescNew;

/**
 *客队ID
 */
@property(nonatomic,strong)UILabel *visitTeamId;


/**
 *联赛名字
 */
@property(nonatomic,strong)UILabel *leagueName;



/**
 *客队Logo
 */
@property(nonatomic,strong)UILabel*visitLogoUrl;




/**
 *比赛状态--数字
 */
@property(nonatomic,strong)UILabel*matchStatus;



/**
 * 比分
 */
@property(nonatomic,strong)UILabel *scoreLabel;

/**
 *主队图标网址
 */
@property(nonatomic,strong)UILabel *hostLogoUrl;

/**
 *联赛ID
 */
@property(nonatomic,strong)UILabel*leagueId;


/**
 *比赛ID
 */
@property(nonatomic,strong)UILabel*matchId;



/**
 *比赛时间
 */
@property(nonatomic,strong)UILabel*matchDay;



/**
 *比赛时间--小时
 */
@property(nonatomic,strong)UILabel*matchTime;



/**
 *客队ID
 */
@property(nonatomic,strong)UILabel *hostTeamId;

/**
 *客队名字
 */
@property(nonatomic,strong)UILabel*visitName;


/**
 *客队球数
 */
@property(nonatomic,strong)UILabel*visitGoal;


@property(nonatomic,strong)UIView *leftView;
@property(nonatomic,strong)UIView *centerView;

@property(nonatomic,strong)UILabel *vsLabel;



@end





@implementation FirstFolltballViewCell







-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        
        
        CGFloat leftWidth = kScreenIp6(100);
        CGFloat rightWidth = kScreenIp6(50);
        CGFloat centerWidth = kScreenWidth - (leftWidth + kScreenIp6(10)) - rightWidth;
        CGFloat partHeight = self.contentView.bounds.size.height;
        
#pragma mark - 左视图
        
        self.leftView = [[UIView alloc] initWithFrame:CGRectMake(kScreenIp6(10), 0, leftWidth, partHeight)];
        [self.contentView addSubview:_leftView];
        
        //比赛顺序
        self.matchOrder = [[UILabel alloc]initWithFrame:CGRectMake(0, kScreenIp6(20), leftWidth, kScreenIp6(20))];
        self.matchOrder.font = [UIFont systemFontOfSize:14];
        self.matchOrder.textColor = [UIColor colorWithWhite:0.400 alpha:1.000];
        [self.leftView addSubview:_matchOrder];
        
        
        
        //联赛名字
        self.leagueName = [[UILabel alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(self.matchOrder.frame) +  kScreenIp6(10) , leftWidth/2 , kScreenIp6(20))];
        self.leagueName.font = [UIFont systemFontOfSize:12];
        self.leagueName.textColor = [UIColor colorWithWhite:0.400 alpha:1.000];
        [self.leftView addSubview:_leagueName];
        
        
        //比赛时间
        self.matchTime = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.leagueName.frame), CGRectGetMinY(self.leagueName.frame), leftWidth/2,kScreenIp6(20))];
        self.matchTime.font = [UIFont systemFontOfSize:12];
        self.matchTime.textColor = [UIColor colorWithWhite:0.400 alpha:1.000];
        [self.leftView addSubview:_matchTime];
        
        
        
#pragma mark - 中视图
    
        self.centerView = [[UIView alloc] initWithFrame:CGRectMake(leftWidth + kScreenIp6(10), 0, centerWidth, kScreenIp6(90))];
        [self.contentView addSubview:_centerView];
        
        CGFloat vsWidth = kScreenIp6(90);
        CGFloat teamWidth = (centerWidth - vsWidth) / 2;
        
        //VS
        self.vsLabel = [[UILabel alloc]initWithFrame:CGRectMake(teamWidth,kScreenIp6(20),vsWidth, kScreenIp6(40))];
        self.vsLabel.textAlignment = 1;
        self.vsLabel.textColor = [UIColor colorWithRed:0.283 green:0.684 blue:0.165 alpha:1.000];
        self.vsLabel.font = [UIFont fontWithName:@"DB LCD Temp" size:15];
        [self.centerView addSubview:_vsLabel];
        
        // 比分
        self.scoreLabel = [[UILabel alloc]initWithFrame:CGRectMake(teamWidth,kScreenIp6(20),vsWidth, kScreenIp6(40))];
        self.scoreLabel.textAlignment = NSTextAlignmentCenter;
        self.scoreLabel.textColor = [UIColor colorWithRed:0.266 green:0.643 blue:0.155 alpha:1.000];
        self.scoreLabel.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:15];
        self.scoreLabel.adjustsFontSizeToFitWidth = YES;
        [self.centerView addSubview:_scoreLabel];
        
        //客队
        self.visitName = [[UILabel alloc]initWithFrame:CGRectMake(0, kScreenIp6(20),teamWidth, kScreenIp6(40))];
        self.visitName.font = [UIFont boldSystemFontOfSize:15];
        self.visitName.textAlignment = 2;
        [self.centerView addSubview:_visitName];
        
        
        //主队
        self.hostName = [[UILabel alloc]initWithFrame:CGRectMake(teamWidth + vsWidth ,kScreenIp6(20), teamWidth, kScreenIp6(40))];
        self.hostName.font = [UIFont boldSystemFontOfSize:15];
        [self.centerView addSubview:_hostName];
        
        
        // 比赛状态
        self.statusDescNew = [[UILabel alloc] initWithFrame:CGRectMake(teamWidth, CGRectGetMaxY(self.visitName.frame), vsWidth, kScreenIp6(20))];
        self.statusDescNew.textAlignment = 1;
        self.statusDescNew.font = [UIFont systemFontOfSize:13];
        [self.centerView addSubview:_statusDescNew];
        
        
        
#pragma mark - 右视图
        
        //收藏图片
        self.attentionIcon = [UIButton buttonWithType:UIButtonTypeSystem];
        self.attentionIcon.tintColor = [UIColor clearColor];
        self.attentionIcon.frame = CGRectMake(kScreenWidth - rightWidth, kScreenIp6(20), rightWidth, rightWidth);
        
        [self.contentView addSubview:_attentionIcon];
        
        
        
        //线
        UIView *footLineView = [[UIView  alloc]initWithFrame:CGRectMake( 0, CGRectGetMaxY(self.centerView.frame) - kScreenIp6(1), kScreenWidth, 0.5)];
        
        footLineView.backgroundColor = [UIColor colorWithWhite:0.699 alpha:1.000];
        
        [self addSubview:footLineView];
        
        
        
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    return self;
}

-(void)setCellValueWithModel:(FirstFootballModel *)model
{
    NSMutableString *order = [model.matchOrder mutableCopy];
    [order insertString:@" " atIndex:2];
    self.matchOrder.text = order;
    self.leagueName.text = model.leagueName;
    
    self. matchTime.text = model.matchTime;

    self.hostName.text = model.hostName;
    self.visitName.text = model.visitName;
    
    self.statusDescNew.text = model.statusDesc;
    
    if ([model.statusDesc isEqualToString:@"未开赛"])
    {
        self.vsLabel.text = @"VS";
        self.scoreLabel.text = @"";
        self.statusDescNew.textColor = [UIColor colorWithRed:0.283 green:0.684 blue:0.165 alpha:1.000];
    }
    else
    {
        self.scoreLabel.text = [NSString stringWithFormat:@"%@ : %@",model.visitGoal,model.hostGoal];
        self.vsLabel.text = @"";
        self.statusDescNew.textColor = [UIColor colorWithWhite:0.400 alpha:1.000];

    }

}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
